<?php
/**
  * //w/w/w.s/h/u/o/t//u/p/u c/o/m  说 图/谱/源/码/分/享
 */
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/12 0012
 * Time: 11:08
 */
defined("IN_IA")or exit("Access denied");
global $_GPC,$_W;
$uniacid=$_GPC['uniacid'];
$op=$_GPC['op'] ? $_GPC['op'] :"getData";
if($op=='getData'){
    $request=array();
    $parentData=pdo_getall('cqkundian_farm_problem_type',array('uniacid'=>$uniacid,'status'=>1,'pid'=>0),'','','rank asc');
    $typeData=pdo_getall('cqkundian_farm_problem_type',array('uniacid'=>$uniacid,'status'=>1,'pid'=>$parentData[0]['id']),'','','rank asc');
    for ($i=0;$i<count($typeData);$i++){
        $problemData=pdo_getall('cqkundian_farm_problem',array('type_id'=>$typeData[$i]['id'],'uniacid'=>$uniacid,'status'=>1),'','','rank asc');
        for ($j=0;$j<count($problemData);$j++){
            $problemData[$j]['isShow']=false;
            $problemData[$j]['index']=$j+1;
        }
        $typeData[$i]['items']=$problemData;
    }
    $request['parentData']=$parentData;
    $request['typeData']=$typeData;

    //设置信息
    $setCon=array(
        'ikey'=>array('is_open_service','service_icon'),
        'uniacid'=>$uniacid,
    );
    $setData=pdo_getall('cqkundian_farm_set',$setCon);
    $setDataList=array();
    foreach ($setData as $key => $value) {
        $setDataList[$value['ikey']]=$value['value'];
    }
    $request['setData']=$setDataList;
    echo json_encode($request);die;
}

//切换分类
if($op=='changeType'){
    $typeData=pdo_getall('cqkundian_farm_problem_type',array('uniacid'=>$uniacid,'status'=>1,'pid'=>$_GPC['pid']),'','','rank asc');
    for ($i=0;$i<count($typeData);$i++){
        $problemData=pdo_getall('cqkundian_farm_problem',array('type_id'=>$typeData[$i]['id'],'uniacid'=>$uniacid,'status'=>1),'','','rank asc');
        for ($j=0;$j<count($problemData);$j++){
            $problemData[$j]['isShow']=false;
            $problemData[$j]['index']=$j+1;
        }
        $typeData[$i]['items']=$problemData;
    }
    $request['typeData']=$typeData;
    echo json_encode($request);die;
}